#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int securityCheck(vector<int>& capacities, int k) {
        int n = capacities.size(), m = k + 200, mod = 1e9 + 7;
        vector<vector<int>> dp(n, vector<int>(m + 1));
        dp[0][k]++;
        if (k >= capacities[0] - 1) dp[0][k - capacities[0] + 1]++;
        for (int i = 1; i < n; i++)
            for (int j = 0; j <= m; j++) {
                dp[i][j] = dp[i - 1][j];
                if (j + capacities[i] - 1 <= m) dp[i][j] = (dp[i][j] + dp[i - 1][j + capacities[i] - 1]) % mod;
            }
        // for(int i = 0; i < n; i++) {
        //     for(int j = 0; j <= 10; j++) cout << dp[i][j] << ' ';
        //     cout << endl; 
        // }
        return dp[n - 1][0];
    }
};